home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_Tix.idb / usr / freeware / lib / tix4.1 / demos / samples / CmpImg.tcl.z / CmpImg.tcl
Encoding:
Text File  |  1999-01-26  |  1.8 KB  |  61 lines

  1. # Tix Demostration Program
  2. #
  3. # This sample program is structured in such a way so that it can be
  4. # executed from the Tix demo program "widget": it must have a
  5. # procedure called "RunSample". It should also have the "if" statment
  6. # at the end of this file so that it can be run as a standalone
  7. # program using tixwish.
  8.  
  9. # This file demonstrates the use of the compound images: it uses compound
  10. # images to display a text string together with a pixmap inside
  11. # buttons
  12. #
  13. proc RunSample {w} {
  14.  
  15.     set img0 [tix getimage network]
  16.     set img1 [tix getimage harddisk]
  17.  
  18.     button $w.hdd -padx 4 -pady 1 -width 120
  19.     button $w.net -padx 4 -pady 1 -width 120
  20.  
  21.     # Create the first image: we create a line, then put a string,
  22.     # a space and a image into this line, from left to right.
  23.     # The result: we have a one-line image that consists of three
  24.     # individual items
  25.     #
  26.     set hdd_img [image create compound -window $w.hdd]
  27.     $hdd_img add line
  28.     $hdd_img add text -text "Hard Disk" -underline 0
  29.     $hdd_img add space -width 7
  30.     $hdd_img add image -image $img1
  31.  
  32.     # Put this image into the first button
  33.     #
  34.     $w.hdd config -image $hdd_img
  35.  
  36.     # Create the second compound image. Very similar to what we did above
  37.     #
  38.     set net_img [image create compound -window $w.net]
  39.     $net_img add line
  40.     $net_img add text -text "Network" -underline 0
  41.     $net_img add space -width 7
  42.     $net_img add image -image $img0
  43.  
  44.     $w.net config -image $net_img
  45.  
  46.     # The button to close the window
  47.     #
  48.  
  49.     button $w.clo -pady 1 -text Close -command "destroy $w"
  50.  
  51.     pack $w.hdd $w.net $w.clo -side left -padx 10 -pady 10 -fill y -expand yes
  52. }
  53.  
  54. if {![info exists tix_demo_running]} {
  55.     wm withdraw .
  56.     set w .demo
  57.     toplevel $w
  58.     RunSample $w
  59.     bind .demo <Destroy> exit
  60. }
  61.